/*********************************************************************
*                                                                    *
* This is the Header file of where general structures are defined    * 
*                                                                    *
*                                                                    *
*********************************************************************/

#include "first_macro_2d.h"  /* place where dimensions and float are defined */

#ifdef STRUCTS_2D_H
#else
#define STRUCTS_2D_H

/* ----------------> STRUCTURES <---------------------------------- */

struct field {
    FLOAT *u_comp;
};

struct field_array {
    /* Value of Field at gridpoint*/
    FLOAT *u[N_FIELDS];
FLOAT time;                   /* time at which the values are taken*/
};


struct deriv_array {
    FLOAT *du[N_DERIVS];
FLOAT time;                   /* time at which the values are taken*/
};

struct aux_array {
    FLOAT *u_aux[N_AUX];
FLOAT time;                   /* time at which the values are taken*/
};

struct s_field_array {
  FLOAT *s_x_0_u[N_FIELDS_MPI];  /* boundary values, these are sides x=xi*/ 
  FLOAT *s_x_1_u[N_FIELDS_MPI];  /* boundary values, these are sides x=xf*/ 

  FLOAT *s_y_0_u[N_FIELDS_MPI];  /* boundary values, these are sides y=yi */
  FLOAT *s_y_1_u[N_FIELDS_MPI];  /* boundary values, these are sides y=yf*/


FLOAT time;                   /* time at which the values are taken*/
};

struct gcs {
  int g;
  int c;
  int s;
};

struct grid_2d {
  int grid;                /* The grid of this processor */
  int n_grids;         /* The total number of grids */
  int n_gridpts_1; /* Number of gridpoints in coordinate 1*/
  int n_gridpts_2; /* Number of gridpoints in coordinate 2*/
  int start_grid_1;  /* Starting value for grid (ussually = zero) */
  int final_grid_1;  /* Final value for the grid (ussually = n_gridpts) */
  int start_grid_2;  /* Starting value for grid (ussually = zero) */
  int final_grid_2;  /* Final value for the grid (ussually = n_gridpts) */
  int start_grid_3;  /* Starting value for grid (ussually = zero) */
  int final_grid_3;  /* Final value for the grid (ussually = n_gridpts) */
  int n_grid_pts; /* total number of gridpoints (n_gridpts_1*n_gridpts_2) */

  struct gcs gcs_send[N_GRIDS][DIM][2]; /* here store the adjoint grid to given grid and side */
  struct gcs gcs_recv[N_GRIDS][DIM][2]; /* here store the adjoint grid to given grid and side */

  /* normals to sides */

  FLOAT nx[DIM][2];
  FLOAT ny[DIM][2];

  /* if excision is valid. This values are given in first_macro.h */
#ifdef EXCISION
  int exc_grid_1;
  int exc_grid_2;
#endif

  int n_fields;  /* Number of fields     */
  int data_steps; /* Number of time steps where data is collected */
  int int_steps; /* Number of internal time steps inbetween data collecting */
  FLOAT initial_time; /* Initial time */
  FLOAT final_time; /* Final time */
  FLOAT initial_x;
  FLOAT final_x;
  FLOAT initial_y;
  FLOAT final_y;

};



struct plot_2d {
  int n_plots;            /* Number of plots to be produced */
  char name[N_PLOTS][30]; /* Array of names for plots */
  char window_name[N_PLOTS][100]; /* Array of names for plots */
/*   FLOAT plot_field[N_PLOTS][N_GRID_PLOT_PTS_1][N_GRID_PLOT_PTS_2][N_GRID_PLOT_PTS_3];  */ 



/* Fields to plot */

#ifdef NETCDF
    double *plot_field;
#endif
#ifdef SDF
/* changed so for reading with fortran convention */
double  *plot_field;
double *coordinate_values;
#endif
#ifdef SV
    float  *plot_field;
#endif

  int pointers[N_PLOTS];  /* Relation between fields and plot names */
  int grid_plot_pts_1;      /* Number of gridpoints in plots */
  int factor_1;             /* Factor between gridpts and gridplotpts */ 
  int grid_plot_pts_2;      /* Number of gridpoints in plots */
  int factor_2;             /* Factor between gridpts and gridplotpts */ 
  int n_gridpts_plot;
  FLOAT initial_x;       /* Initial value for space coordinate */
  FLOAT final_x;         /* Final value for space coordinate */
  FLOAT initial_y;       /* Initial value for space coordinate */
  FLOAT final_y;         /* Final value for space coordinate */
  FLOAT initial_time;       /* Initial value for time coordinate */
  FLOAT final_time;         /* Final value for time coordinate */ 
#ifdef NETCDF
  int tic; /* ploting frame, used to mark time in data */
#endif
#ifdef SV
  char JSERHOST_env[40];  /* Host where data is sent when using scivis */
#endif
  char input_file_name[40];   /* File name where input data goes */
  char output_file_name[40];   /* File name where output data goes */
  FILE *input_data_file_ptr;        /* pointer to the open file */
  FILE *output_data_file_ptr;
  int time_level; // time level
//  int prev_time_level;
  int time_stamp;               // value to use in the name of plot file and also to tell that data should be read from files.
  int prev_time_stamp;
};


struct entry{
  char *name;    /* Name of data fields in web        */
  char *val;     /* Value of data fields given in web */
};

struct entries{
  struct entry entry[MAX_ENTRIES];
  int dim;      /* Real dimension of entry           */
};



#endif
